package com.abc.bookstore.argot;

import com.abc.bookstore.Book;
import com.abc.bookstore.BookNotFoundException;
import com.abc.bookstore.Bookstore;
import com.abc.bookstore.IBookstore;
import com.argot.ResourceDictionaryLoader;
import com.argot.TypeException;
import com.argot.TypeLibrary;
import com.argot.auto.TypeArrayMarshaller;
import com.argot.auto.TypeBeanMarshaller;
import com.argot.auto.TypeSimpleReader;
import com.argot.auto.TypeSimpleWriter;
import com.argot.remote.MetaInterface;
import com.argot.remote.MetaRemoteException;


public class BookLoader 
extends ResourceDictionaryLoader
{
	public final static String DICTIONARY = "bookstore.dictionary";
	
	public BookLoader()
	{
		super( DICTIONARY );
	}
	
	public String getName()
	{
		return DICTIONARY;
	}
	
	public void bind( TypeLibrary library ) 
	throws TypeException
	{
		library.bind( library.getTypeId("book","1.0"),
				new TypeBeanMarshaller(),
				new TypeBeanMarshaller(),
				Book.class);
		
		library.bind( library.getTypeId("booklist","1.0"), 
				new TypeArrayMarshaller(),
				new TypeArrayMarshaller(),
				Book[].class);
		
		library.bind( library.getTypeId(BookNotFoundException.TYPENAME, "1.0"),
				new MetaRemoteException.Reader( BookNotFoundException.class ),
				new MetaRemoteException.Writer(),
				BookNotFoundException.class);
		
		library.bind( library.getTypeId(IBookstore.TYPENAME, "1.0"),
				new TypeSimpleReader(new MetaInterface.MetaInterfaceReader()),
				new TypeSimpleWriter(new MetaInterface.MetaInterfaceWriter()),
				IBookstore.class);
		
		library.addClassAlias( library.getTypeId(IBookstore.TYPENAME,"1.0"), Bookstore.class);
	}
}
